package com.sikaryofficial.backend.constant;

import cn.hutool.core.text.CharSequenceUtil;
import com.sikaryofficial.common.core.constant.PointRuleConstant;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author : qinjinyuan
 * @desc : 积分规则枚举
 * @date : 2023/10/31 19:23
 */
@Getter
@AllArgsConstructor
public enum PointRuleEnum {
    /**
     * 一支烟-100积分
     */
    SCAN_CODE(PointRuleConstant.SCAN_CODE, "电子烟扫码评价"),
    SCAN_REGISTER(PointRuleConstant.SCAN_REGISTER, "扫码注册"),
    STORE_EVALUATE(PointRuleConstant.STORE_EVALUATE, "门店分享"),
    EVALUATE(PointRuleConstant.EVALUATE, "产品评价"),
    ARTICLE_PUBLISH_HOME(PointRuleConstant.ARTICLE_PUBLISH_HOME, "首页发帖"),
    OWNER_INFO_MODIFY(PointRuleConstant.OWNER_INFO_MODIFY, "完善个人信息"),
    ARTICLE_RECEIVED_LIKE(PointRuleConstant.ARTICLE_RECEIVED_LIKE, "收到的文章点赞"),
    ARTICLE_BROWSE(PointRuleConstant.BROWSE_DURATION_HOME, "文章浏览时长"),
    ARTICLE_EVALUATE(PointRuleConstant.ARTICLE_EVALUATE, "文章评价"),
    ARTICLE_EVALUATE_REPLY(PointRuleConstant.ARTICLE_EVALUATE_REPLY, "文章评价回复"),
    ARTICLE_LIKE(PointRuleConstant.ARTICLE_LIKE, "文章点赞"),
    ARTICLE_APPOINT_TOPIC(PointRuleConstant.ARTICLE_APPOINT_TOPIC, "发帖带指定topic"),
    ARTICLE_TOP_UP(PointRuleConstant.ARTICLE_TOP_UP, "文章被置顶"),
    SCAN_TASK(PointRuleConstant.SCAN_TASK, "扫码任务"),
    ARTICLE_VIEW(PointRuleConstant.ARTICLE_VIEW_LIKE, "浏览并点赞官方发布的带Event字样的帖子")
 ;
    private final String code;
    private final String name;

    public static PointRuleEnum getValueByCode(String code) {
        return Arrays.stream(PointRuleEnum.values())
                .filter(pointRuleEnum -> CharSequenceUtil.equals(code, pointRuleEnum.getCode()))
                .findFirst().orElse(null);
    }

}
